import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:nyh_motorcade_app/routes/routes.dart';
import 'package:nyh_motorcade_app/styles/colors.dart';
import 'package:nyh_motorcade_app/utils/format_utils.dart';
import 'package:nyh_motorcade_app/widgets/custom_app_bar.dart';
import 'package:nyh_motorcade_app/widgets/left_right_text.dart';
import 'package:nyh_motorcade_app/widgets/multi_state/multi_state_widget.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'account_amount_remind_controller.dart';

class AccountAmountRemindPage extends StatelessWidget {
  final controller = Get.put(AccountAmountRemindController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colours.color_background,
      appBar: CustomAppBar(
        context: context,
        title: "账户余额提醒",
        actions: [
          TextButton(
            onPressed: () {
              if (controller.companyInfoEntity != null) {
                Get.toNamed(Routes.companyManage, arguments: controller.companyInfoEntity);
              }
            },
            child: Text(
              "修改提醒额度",
              style: TextStyle(
                color: Colours.color_theme,
                fontSize: 14.sp,
              ),
            ),
            style: ButtonStyle(
              tapTargetSize: MaterialTapTargetSize.shrinkWrap,
              minimumSize: MaterialStateProperty.all(Size(0, 0)),
              padding: MaterialStateProperty.all(EdgeInsets.symmetric(vertical: 5.w, horizontal: 16.w)),
            ),
          ),
        ],
      ),
      body: GetBuilder<AccountAmountRemindController>(
        builder: (controller) {
          return MultiStateWidget(
            child: Column(
              children: [
                SizedBox(
                  height: 12.w,
                ),
                LeftRightText(
                  textLeft: "当前账户总余额(元)",
                  textRight: FormatUtils.formatMoney(controller.totalAmount),
                ),
                Divider(
                  color: Colours.color_divider,
                  height: 1.w,
                  thickness: 1.w,
                ),
                LeftRightText(
                  textLeft: "公司账户余额(元)",
                  textRight: FormatUtils.formatMoney(controller.companyAmount),
                ),
                Divider(
                  color: Colours.color_divider,
                  height: 1.w,
                  thickness: 1.w,
                ),
                LeftRightText(
                  textLeft: "车队账户余额(元)",
                  textRight: FormatUtils.formatMoney(controller.motorcadeAmount),
                ),
                Divider(
                  color: Colours.color_divider,
                  height: 1.w,
                  thickness: 1.w,
                ),
                LeftRightText(
                  textLeft: "卡账户余额(元)",
                  textRight: FormatUtils.formatMoney(controller.cardAmount),
                ),
              ],
            ),
            state: controller.multiState,
            onRetry: () {
              controller.onRetry();
            },
          );
        },
      ),
    );
  }
}
